// 导入请求实例
import request from './request'

// 登录接口
export const reqLogin = (data) => {
  return request({
    method: 'post',
    url: '/login',
    data,
  })
}

// 获取分类
export const reqGetCate = () => {
  return request({
    method: 'get',
    url: '/getcate',
  })
}

// 获取文章
export const reqGetArticle = ({ page, pagesize, input }) => {
  return request({
    method: 'get',
    url: `/getarticle?page=${page}&pagesize=${pagesize}&input=${input}`,
  })
}

// 添加文章
export const reqAddArticle = (data) => {
  return request({
    method: 'post',
    url: `/addarticle`,
    data,
  })
}

// 获取附件
export const reqGetMedia = () => {
  return request({
    method: 'get',
    url: '/getmedia',
  })
}

// 删除附件
export const reqDelMedia = (id) => {
  return request({
    method: 'delete',
    url: '/delmedia?id=' + id,
  })
}

// 添加附件
export const reqAddMedia = (path) => {
  return request({
    method: 'post',
    url: '/addmedia',
    data: {
      path,
    },
  })
}

// 用户登录接口
export const login = (data) => {
  return request({
    method: 'post',
    url: '/login',
    data: {
      // 展开运算符
      ...data,
    },
  })
}

// 获取用户信息
export const reqUserInfo = () => {
  return request({
    method: 'post',
    url: '/getUserInfo',
  })
}

// 获取分类下面的文章总数
export const reqArticleCount = () => {
  return request({
    method: 'get',
    url: '/articlecount',
  })
}
